/*
 * Copyright (c) 2024 endless-sky
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef BASE_INCLUDE_BASE_UTILS_H
#define BASE_INCLUDE_BASE_UTILS_H

#include <string>
#include <vector>
#include <chrono>

namespace El {
namespace Utils {

/**
 * @brief 将utc时间转换为字符串
 * @param utc 32位utc时间戳
 * @return 格式化后的时间字符串
 */
std::string utc32ToString(uint32_t utc);

/**
 * @brief 将utc时间转换为字符串
 * @param utc 64位utc时间戳
 * @return 格式化后的时间字符串
 */
std::string utc64ToString(uint64_t utc);

/**
 * @brief 将系统时间转换为字符串
 * @param tp 系统时间点
 * @return 格式化后的时间字符串
 */
std::string utcToString(std::chrono::system_clock::time_point tp);

/**
 * @brief 获取随机token
 * @param length token长度
 * @return 生成的token字符串
 */
std::string GenerateToken(size_t length);

/**
 * @brief 字符串分割函数
 * @param input 要分割的字符串
 * @param delimiter 分隔符
 * @param result 分割后的子字符串列表
 */
void Split(const std::string &input, const std::string &delimiter, std::vector<std::string> &result);

} // namespace Utils
} // namespace El

#endif // BASE_INCLUDE_BASE_UTILS_H